package com.xxxx.yoyo.service.impl;

import java.util.List;

import com.xxxx.yoyo.bean.Top;
import com.xxxx.yoyo.dao.ITopDao;
import com.xxxx.yoyo.dao.impl.TopDaoImpl;
import com.xxxx.yoyo.service.ITopService;

public class TopServiceImpl implements ITopService {

	private ITopDao topDao = new TopDaoImpl();
	
	/**
	 * 根据宠物的id查询宠物所属的榜单
	 * @param goodsId 宠物的id
	 * @return 返回宠物所属榜单列表
	 */
	@Override
	public List<Top> getTopListByGoodsId(int goodsId) {
		List<Top> topList = topDao.selectTopListByGoodsId(goodsId);
		return topList;
	}

	/**
	 * 添加榜单信息
	 * @param top 榜单对象
	 * @return 添加成功返回true，失败返回false
	 */
	@Override
	public boolean addTop(Top top) {
		int row = topDao.insertTop(top);
		if(row == 1){
			return true;
		}else {
			return false;
		}
	}

	/**
	 * 删除榜单信息
	 * @param top 榜单对象
	 * @return 删除成功返回true，失败返回false
	 */
	@Override
	public boolean deleteTop(Top top) {
		int row = topDao.deleteTop(top);
		if(row == 1){
			return true;
		}else {
			return false;
		}
	}

}
